<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * FormativeLab
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package		FormativeLab
 * @author		FormativeLab Dev Team
 * @copyright	Copyright (c) 2011 - 2013, FormativeLab, Inc.
 * @license		http://www.formativesoft.com/license/
 * @link		http://www.formativesoft.com/
 * @since		Version 2.0
 * @filesource ./application/controllers/Welcome.php
 */

// ------------------------------------------------------------------------

/**
 * FormativeLab Welcome Controller
 *
 * @package		FormativeLab
 * @subpackage	controllers
 * @category	controllers
 * @author		Formative Soft Ltd
 * @link		http://www.formativesoft.com/
 */

// ------------------------------------------------------------------------

class Welcome extends FSL_Controller {

	static $helpesr	= array();
	static $models	= array();

	public function __construct(){
        parent::__construct('defaults');
		$this->load->helper(self::$helpers);
		$this->load->model(self::$models);
    }
	
	public function index()
	{
		$this->load->view('welcome_message');
	}
	
	public function info(){
		$module = $this->router->fetch_module();
		echo empty($module);
		echo "<br/>";
		echo $this->router->fetch_class();
		echo "<br/>";
		echo $this->router->fetch_method();
	}
	
	public function signup(){
		$this->load->library('form_validation');
		if ($this->form_validation->run() == FALSE){
			$this->load->view('myform');
		}else{
			$this->load->view('formsuccess');
		}
	}
	
	public function userNameExists($userName){		
		if ($userName == 'test'){
			$this->form_validation->set_message('Username', 'The %s field can not be the word "test"');
			return FALSE;
		} else {
			return TRUE;
		}
	
	}
	
	public function crop(){
		$content					= file_get_contents('./resources/springsource.png', true);
		//var_dump($content);
		$tempfile					= tempnam(sys_get_temp_dir(), 'crop');
		file_put_contents ( $tempfile , $content, LOCK_EX);
		
		$config['image_library'] 	= 'gd2';
		$config['source_image'] 	= $tempfile; //'./resources/springsource.png';
		//$config['new_image'] 		= './resources/springsource1.png';
		$config['dynamic_output'] 	= TRUE;
		$config["width"] 			= 100;
		$config["height"] 			= 100;
		$config['x_axis'] 			= 10;
		$config['y_axis'] 			= 60;
		
		$this->load->library('image_lib');      
		$this->image_lib->initialize($config); 

		if ( ! $this->image_lib->crop()){
			echo $this->image_lib->display_errors();
		}
		unlink($tempfile);
	}
	
	public function ajax(){
		//$this->load->view('ajax');
		echo BASEPATH,'<br/>', APPPATH;
		
	}
	
	public function calender(){
		$this->load->library('calendar');
		echo $this->calendar->generate(2006, 6);
	}
	
	public function pagination($id=0){
		$config=array(
			'base_url'         => base_url()."welcome/pagination/",
			'total_rows'       => 200,
			'per_page'         => 20,
			'num_links'        => 10,
			'uri_segment'      => 3,
			'use_page_numbers' => TRUE
		);
		$this->load->library('pagination');
		$this->pagination->initialize($config);
		echo $this->pagination->create_links();	
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */